#! /bin/bash
# 自动建立hosts.allow和hosts.deny

ipAllow=`ip addr | grep -E 'ens33$' | awk '{print $2}' | awk -F '/' '{print $1}' | awk -F '.' '{print $1"."$2"."$3"."}'`
services="sshd vsftpd in.qpopper"
allowFile="/etc/hosts.allow"
denyFile="/etc/hosts.deny"


echo "ALL: ALL" > $denyFile

: > $allowFile
for service in $services
do
  echo "$service: $ipAllow" >> $allowFile
done

echo "auto bulid hosts.allow and hosts.deny successful!"
